//
//  myResume.swift
//  万才信息App
//
//  Created by 鹏速科技 on 16/8/1.
//  Copyright © 2016年 万才信息. All rights reserved.
//

import UIKit

class resumeListController: UITableViewController{
    
    private var resumeList = [listResume]()
    
    @IBOutlet var lvResume: UITableView!
    
//    private let waitingForJobFresh=waitingAlertUtil(msg: "加载中...")
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        lvResume.dataSource=self
//        隐藏分割线
        lvResume.separatorStyle = UITableViewCellSeparatorStyle.None
        lvResume.layer.borderWidth = 10
        lvResume.backgroundColor = UIColor.hexStringToColor("#EFEFEF")
        lvResume.layer.borderColor = UIColor.hexStringToColor("#EFEFEF").CGColor
//        lvResume.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        loadDate()
    }
    
    private func loadDate(){
        resumeManager.GetResumeList(userUtil.getCurrUserId(), successCallback: { (theRetList) in
            //            self.waitingForJobFresh.stop()
            self.resumeList=theRetList
            self.lvResume.reloadData()
        }) { (error) in
            warningAlertUtil(title: "错误", msg: error).show(self)
        }
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    
    //    DataSource方法
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.resumeList.count
    }
    
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cellIndentifer="resumeList"
        
        let cell:resumeCell!=tableView.dequeueReusableCellWithIdentifier(cellIndentifer) as! resumeCell
        
        let row=indexPath.row
        cell.setResume(resumeList[row])
//        设置背景样式
        let tmp:UIView = UIView()
        cell.backgroundView = tmp
        tmp.layer.borderWidth = 5
//        tmp.layer.cornerRadius = 5
        tmp.layer.borderColor = UIColor.hexStringToColor("#EFEFEF").CGColor
        return cell
    }
    

    
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "toSingleResume" {
            if let indexPath = self.lvResume.indexPathForSelectedRow {
                let  ID = resumeList[indexPath.row].ResumeId
                print("选中了单个cell，跳转到单简历页面，其中resumeId=")
                print(ID)
                (segue.destinationViewController as! singleResumeController).resumeId = ID
            }
        }
    }

    
    
    
}